#ifndef __DATALITE__
#define __DATALITE__
#include <string>
#include <vector>
#include <set>
using namespace std;
class datalite {

	string _file;
	int64_t _position;
	int64_t _last_position;
	int64_t _position_channel;
	int64_t _last_position_channel;
	int create();
	set<string> _found_links;
	public:
		datalite(): _file("database.sqlite"), _position(1), _last_position(1), _position_channel(0), _last_position_channel(0){}
		datalite(const string& file);
		int get_mark(int64_t position);
		int set_mark(int64_t position);
		int insert_row(const string& link, const string& title = "", const string& description = "");
		int delete_news();
		int update_title(const string& title);
		int search(const string& pattern);
		int show_unique_database_fields(const string& sql);
		int update_metainfo(const string& metainfo);
		string get_one_new(int64_t position);
		string get_metainfo(const int64_t& position);
		string get_title(const int64_t& position);
		string get_file(){ return _file; }
		void set_file(const string& file){ _file = file; }
		void insert_datalite(datalite& db);
		string get_new_line();
		string get_new_channel();
		string get_link(int64_t position);
		string get_channel(int64_t position);
		bool is_valid_line();
		bool is_valid_channel();
		int64_t get_position(){ return _position; }
		int64_t get_last_position();
		int64_t get_last_channel();
		void set_position(int64_t position);
		int bulk_insert(const vector<string>& links, const vector<string>& title, const vector<string>& description);
		void show_news();
		void export_dl(const string& file = "database.conf");
		void import_dl(const string& file = "database.conf");
		datalite& operator=(datalite& src);
		struct Invalid{
			Invalid(const string& reason):reason_(reason){}
			string reason()const{return reason_;}
			private:
				string reason_;
		};
};
#endif
